package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @author Administrator
 * @Description
 * @date 2022/5/23 11:16
 **/
public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Person p = new Person("lisi", 21);
        System.out.println(p);
        Class cls = Class.forName("reflect.Person");

        Constructor constructor = cls.getConstructor(String.class, int.class);
        Object wangwu = constructor.newInstance("wangwu", 13);
        System.out.println(wangwu);

    }
}
